//
//  InstallerPointsView.swift
//  ezyform
//
//  Created by MoennigQ on 26/12/19.
//  Copyright © 2019 Client.Solution Pty Ltd. All rights reserved.
//

import UIKit
import SnapKit
class InstallerPointsView: MeModelVCBaseView {
    let totalPointsLabel = BaseLabel()
    let tipBtn = UIButton()
    let tableView = TableView()
    
    override func setUpviews() {
        //
        let contentView = UIView()
        contentView.backgroundColor = .white
        self.addSubview(contentView)
        contentView.snp.makeConstraints { make in
            make.top.equalTo(self.topBackView.snp.bottom)
            make.left.right.bottom.equalToSuperview()
        }
        //
        let topImageViewMargin: CGFloat = 20
        let topImageViewHeight = (APPConfig.WidthForPortrait - topImageViewMargin * 2) / 343 * 176
        let topImageView = UIImageView(image: R.image.me_installerpoint_top_bg())
        contentView.addSubview(topImageView)
        topImageView.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(20)
            make.left.equalTo(topImageViewMargin)
            make.right.equalTo(-topImageViewMargin)
            make.height.equalTo(topImageViewHeight)
        }
        //
        totalPointsLabel.text = "-"
        totalPointsLabel.textColor = .white
        totalPointsLabel.setFont(R.font.dinAlternateBold(size: 32))
        contentView.addSubview(totalPointsLabel)
        totalPointsLabel.snp.makeConstraints { (make) in
            make.height.width.greaterThanOrEqualTo(0)
            make.centerX.equalTo(topImageView)
            make.centerY.equalTo(topImageView).offset(-20)
        }
        //
        let currentPointLabel = BaseLabel()
        currentPointLabel.text = "Current Points"
        currentPointLabel.textColor = UIColor(hexStr: "#FFFFFFB3")
        currentPointLabel.setFont(R.font.interMedium(size: 15))
        contentView.addSubview(currentPointLabel)
        currentPointLabel.snp.makeConstraints { (make) in
            make.top.equalTo(totalPointsLabel.snp.bottom).offset(2)
            make.centerX.equalToSuperview()
            make.height.width.greaterThanOrEqualTo(0)
        }
        //
        
        tipBtn.setImage(R.image.me_installerpoint_tip(), for: UIControl.State.normal)
        contentView.addSubview(tipBtn)
        tipBtn.snp.makeConstraints { (make) in
            make.right.bottom.equalTo(topImageView)
            make.height.width.equalTo(44)
        }
        
        //
        let pointHistoryLabel = BaseLabel()
        pointHistoryLabel.text = "Points History"
        pointHistoryLabel.textColor = UIColor(hexStr: "#292D32B3")
        pointHistoryLabel.setFont(R.font.interMedium(size: 15))
        contentView.addSubview(pointHistoryLabel)
        pointHistoryLabel.snp.makeConstraints { (make) in
            make.top.equalTo(topImageView.snp.bottom).offset(34)
            make.left.equalToSuperview().offset(20)
            make.height.width.greaterThanOrEqualTo(0)
        }
        //table view
        tableView.separatorStyle = .none
        tableView.backgroundColor = .white
        tableView.layer.cornerRadius = Constant.BackViewCornerRadius
        tableView.layer.shadowOffset = CGSize(width: 0, height: 2)
        tableView.layer.shadowColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.06).cgColor
        tableView.layer.shadowOpacity = 1
        tableView.layer.shadowRadius = 16
        contentView.addSubview(tableView)
        tableView.snp.makeConstraints { (make) in
            make.top.equalTo(pointHistoryLabel.snp.bottom).offset(20)
            make.left.equalToSuperview().offset(20)
            make.right.equalToSuperview().offset(-20)
            make.bottom.equalTo(self.safeAreaLayoutGuide.snp.bottom)
        }
        
        tableView.register(PointHistoryTableViewCell.self, forCellReuseIdentifier: PointHistoryTableViewCell.reuseCellIdentifier)
    }

}
